home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form QWatch
- BackColor = &H00FFFFFF&
- Caption = "Queue Watch"
- ClientHeight = 3525
- ClientLeft = 1470
- ClientTop = 1785
- ClientWidth = 4770
- ForeColor = &H00FF8080&
- Height = 4215
- Icon = QWATCH.FRX:0000
- Left = 1410
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- ScaleHeight = 3525
- ScaleWidth = 4770
- Top = 1155
- Width = 4890
- Begin Timer WakeUp
- Left = 4320
- Top = 3000
- End
- Begin PictureBox AppIcon
- Height = 495
- Left = 2985
- Picture = QWATCH.FRX:0302
- ScaleHeight = 465
- ScaleWidth = 465
- TabIndex = 14
- TabStop = 0 'False
- Top = 3000
- Visible = 0 'False
- Width = 495
- End
- Begin PictureBox Watch
- Height = 495
- Left = 3600
- Picture = QWATCH.FRX:0604
- ScaleHeight = 465
- ScaleWidth = 465
- TabIndex = 4
- Top = 2280
- Width = 495
- End
- Begin PictureBox Queue
- Height = 495
- Left = 3600
- Picture = QWATCH.FRX:0906
- ScaleHeight = 465
- ScaleWidth = 465
- TabIndex = 3
- Top = 1200
- Width = 495
- End
- Begin Frame Frame1
- BackColor = &H00FFFFFF&
- Caption = "Warning Levels"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00FF0000&
- Height = 2655
- Left = 360
- TabIndex = 7
- Top = 720
- Width = 2535
- Begin TextBox RedLevel
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 375
- Left = 1080
- TabIndex = 2
- Text = "30"
- Top = 1920
- Width = 495
- End
- Begin PictureBox Red
- Height = 495
- Left = 360
- Picture = QWATCH.FRX:0C08
- ScaleHeight = 465
- ScaleWidth = 465
- TabIndex = 10
- TabStop = 0 'False
- Top = 1920
- Width = 495
- End
- Begin TextBox YellowLevel
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00C00000&
- Height = 375
- Left = 1080
- TabIndex = 1
- Text = "15"
- Top = 1200
- Width = 495
- End
- Begin PictureBox Yellow
- Height = 495
- Left = 360
- Picture = QWATCH.FRX:0F0A
- ScaleHeight = 465
- ScaleWidth = 465
- TabIndex = 9
- TabStop = 0 'False
- Top = 1200
- Width = 495
- End
- Begin PictureBox Green
- Height = 495
- Left = 360
- Picture = QWATCH.FRX:120C
- ScaleHeight = 465
- ScaleWidth = 465
- TabIndex = 8
- TabStop = 0 'False
- Top = 480
- Width = 495
- End
- Begin Label Label5
- Caption = "Jobs"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 255
- Left = 1680
- TabIndex = 13
- Top = 1920
- Width = 495
- End
- Begin Label Label4
- Caption = "Jobs"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 255
- Left = 1680
- TabIndex = 12
- Top = 1200
- Width = 495
- End
- Begin Label Label2
- BackColor = &H00FFFFFF&
- Caption = "0 Jobs"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00FF0000&
- Height = 255
- Left = 1080
- TabIndex = 11
- Top = 480
- Width = 1335
- End
- End
- Begin ComboBox Server
- Height = 300
- Left = 1200
- Style = 2 'Dropdown List
- TabIndex = 0
- Top = 240
- Width = 3255
- End
- Begin Label Label1
- BackColor = &H00FF0000&
- Caption = "Watch"
- ForeColor = &H00FFFFFF&
- Height = 210
- Left = 3570
- TabIndex = 5
- Top = 2775
- Width = 570
- End
- Begin Label Label6
- BackColor = &H00FF0000&
- Caption = "Queues"
- ForeColor = &H00FFFFFF&
- Height = 210
- Left = 3510
- TabIndex = 15
- Top = 1695
- Width = 705
- End
- Begin Label Label3
- BackColor = &H00FF0000&
- Caption = "&Server"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00FFFFFF&
- Height = 255
- Left = 360
- TabIndex = 6
- Top = 240
- Width = 735
- End
- Begin Menu mFile
- Caption = "&File"
- Index = 1
- Begin Menu mExit
- Caption = "E&xit"
- Index = 2
- End
- Begin Menu mSeperator2
- Caption = "-"
- End
- Begin Menu mAbout
- Caption = "&About..."
- End
- End
- Sub Form_Load ()
- Dim szServers As String * 160
- Dim nEntries As Integer, nTotal As Integer
- Dim nResult As Integer, nIndex As Integer, nParse As Integer
- '*--------------------------------*
- 'query network for list of servers
- '*--------------------------------*
- nResult = NetServerEnum2("", 0, szServers, 160, nEntries, nTotal, &HFFFFFFFF, "")
- '*---------------------------------*
- 'parse results returned in szServers
- '*---------------------------------*
- nIndex = 0: nParse = 1
- While nIndex < nEntries
- nStart = nParse
- '*-------------------------------*
- 'search for ASCIIZ null terminator
- '*-------------------------------*
- While Asc(Mid$(szServers, nParse, 1)) <> 0
- nParse = nParse + 1
- Wend
- '*--------------------------------------------------------------*
- 'use the AddItem Method to add server name to the server list box
- '*--------------------------------------------------------------*
- Server.AddItem Mid$(szServers, nStart, (nParse - nStart)), nIndex
- nParse = nParse + 1
- nIndex = nIndex + 1
- Wend
- End Sub
- Sub Form_Paint ()
- '*----------------------------------------------*
- 'determine if being restored from a 'Watch' state
- '*----------------------------------------------*
- If WakeUp.Interval = 5000 Then
- '*---------------*
- 'de-activate timer
- '*---------------*
- WakeUp.Interval = 0
- '*-----------------------------------------------------*
- 'reset window title from server name to application name
- '*-----------------------------------------------------*
- QWatch.Caption = "Queue Watch"
- '*-------------------------------------------------------------*
- 'reset window icon from server warning state to application icon
- '*-------------------------------------------------------------*
- QWatch.Icon = AppIcon.Picture
- '*----------------------------------------------------------*
- 'immediately invoke queues window if warning is yellow or red
- '*----------------------------------------------------------*
- If nWarning Then Queues.Show 1
- End If
- End Sub
- Sub Label1_Click ()
- '*---------------------------------------------------------------*
- 'allow clicking on the picture text(Watch) by invoking the picture
- '*---------------------------------------------------------------*
- Watch_Click
- End Sub
- Sub Label6_Click ()
- '*----------------------------------------------------------------*
- 'allow clicking on the picture text(Queues) by invoking the picture
- '*----------------------------------------------------------------*
- Queue_Click
- End Sub
- Sub mExit_Click (Index As Integer)
- '*------------------------------------------*
- 'close application by unloading the main form
- '*------------------------------------------*
- Unload QWatch
- End Sub
- Sub Queue_Click ()
- '*-------------------------------------------------------*
- 'verify selection of a server and invoke the queues window
- '*-------------------------------------------------------*
- If Server.Text = "" Then
- MsgBox "No Server Selected.", 16, "Show Queues"
- Else
- Queues.Show 1
- End If
- End Sub
- Sub WakeUp_Timer ()
- Static Share(49) As Share_Info
- Dim Queue As PRQJINFO
- Dim nEntries As Integer, nTotal As Integer, nNeeded As Integer
- Dim nResult As Integer, nShare As Integer, nNewWarning
- Dim szServer As String
- '*-----------------------------------------------------------------*
- 'check whether application is in watch mode or just coming out of it
- '*-----------------------------------------------------------------*
- If WakeUp.Interval = 5000 Then
- szServer = "\\" + QWatch.Caption + ""
- '*---------------------------------------------------*
- 'query specified server for a list of shared resources
- '*---------------------------------------------------*
- nResult = NetShareEnum(szServer, 2, Share(0), 2000, nEntries, nTotal)
- nNewWarning = 0
- For nShare = 0 To nEntries
- If Share(nShare).nType = 1 Then
- '*------------------------------------------------------*
- 'if shared resource is a print queue then get information
- '*------------------------------------------------------*
- nResult = DosPrintQGetInfo(szServer, Share(nShare).lpPath, 1, Queue, 115, nNeeded)
- '*---------------------*
- 'check if printer paused
- '*---------------------*
- If Queue.nStatus = 64 Then
- nNewWarning = 1
- '*----------------------*
- 'check if printer offline
- '*----------------------*
- ElseIf Queue.nStatus = 32 Then
- nNewWarning = 2
- ElseIf Queue.nJobs Then
- '*-----------------------------------*
- 'check if jobs exceed specified levels
- '*-----------------------------------*
- If Queue.nJobs >= Val(YellowLevel.Text) Then nNewWarning = 1
- If Queue.nJobs >= Val(RedLevel.Text) Then nNewWarning = 2
- End If
- End If
- Next
- '*--------------------------------------------------*
- 'update application icon if warning state has changed
- '*--------------------------------------------------*
- If nNewWarning <> nWarning Then
- Select Case nNewWarning
- Case 0
- QWatch.Icon = Green.Picture
- Case 1
- QWatch.Icon = Yellow.Picture
- Case 2
- QWatch.Icon = Red.Picture
- End Select
- nWarning = nNewWarning
- End If
- End If
- End Sub
- Sub Watch_Click ()
- '*--------------------------*
- 'verify selection of a server
- '*--------------------------*
- If Server.Text = "" Then
- MsgBox "No Server Selected.", 16, "Begin Watch"
- GoTo ExitWatchClick
- End If
- '*-----------------------------*
- 'set window title to server name
- '*-----------------------------*
- QWatch.Caption = Server.Text
-
- '*-------------------------------------------------------*
- 'set initial warning state to green and establish the icon
- '*-------------------------------------------------------*
- nWarning = 0
- QWatch.Icon = Green.Picture
- '*------------------*
- 'minimize application
- '*------------------*
- QWatch.WindowState = 1
- '*--------------------------------------*
- 'set the timer to wake up every 5 seconds
- '*--------------------------------------*
- WakeUp.Interval = 5000
- ExitWatchClick:
- End Sub
-